<template>
  <div>
    <div style="margin-top: 10px; margin-bottom: 20px">
      <el-input
          v-model="outOrderId"
          size="default"
          placeholder="想要查询的出库单编号"
          style="width: 200px"
      />
      <el-button type="primary" style="margin-left: 10px" @click = "search">查询</el-button>
    </div>
    <el-divider></el-divider>
    <el-scrollbar>
      <el-table
          ref="multipleTable"
          tooltip-effect="dark"
          :data="tableData"
          style=" width: 100%"
          height="542px"
      >
        <el-table-column type="index" :index="getIndex" label="序号"/>
        <el-table-column prop="outOrderId" label="出库单号"/>
        <el-table-column prop="distributionOrder" label="包含的分发单编号"/>
        <el-table-column prop="distributeTime" label="对应的分发时间"/>
        <el-table-column prop="outTime" label="出库时间"/>
        <el-table-column prop="outWarehouseId" label="出库库房编号"/>
      </el-table>
      <el-pagination
          background
          :page-size=pageSize
          :page-sizes="[10,20,30,40]"
          layout="total, prev, pager, next"
          :total=totalSize
          @current-change="pageChange"
          style="margin-top: 15px"
          :current-page=pageNow
      >
      </el-pagination>
    </el-scrollbar>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "OutOrder",
  data(){
    return{
      outOrderId:'',
      tableData:[
      ],
      pageSize:10,
      pageNow:0,
      totalSize:''
    }
  },
  methods:{
    loadPost(){
      axios.post("http://localhost:1050/outOrder/queryOutOrder",{
        pageNow:this.pageNow,
        pageSize:this.pageSize
      }).then(res=>{
        this.pageNow = 1
        res = res.data
        if (res.code == '200'){
          this.totalSize = res.data.totalRows
          this.tableData = res.data.rowData
        }else {
          this.tableData = []
          this.totalSize = 0
        }
      })
    },

    pageChange(val){
      this.pageNow = val
      console.log(this.pageNow,this.startTime,this.code)
      axios.post("http://localhost:1050/outOrder/queryOutOrder",{
        entryOrderId:this.entryOrderId,
        pageNow:this.pageNow,
        pageSize:this.pageSize
      }).then(res=>{
        res = res.data
        if (res.code == '200') {
          console.log(res.data)
          this.tableData = res.data.rowData
        }else {
          this.tableData = []
          this.totalSize = 0
        }
      })
    },
    getIndex(index){
      index = index + 1 + (this.pageNow - 1) * this.pageSize
      return index
    },
  },

  beforeMount() {
    this.loadPost()
  }
}
</script>

<style scoped>

</style>